package com.ruoyi.system.gameCarrier.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.gameCarrier.domain.GameCarrierNumber;
import com.ruoyi.system.gameCarrier.service.IGameCarrierNumberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 运营商号码表(game_carrier_number)表控制层
 *
 * @author zyy
 * @date 2024-09-02 11:25:30
 */
@RestController
@RequestMapping("/gameCarrierNumber")
public class GameCarrierNumberController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private IGameCarrierNumberService gameCarrierNumberService;

    /**
     * 分页查询所有数据
     *
     * @param gameCarrierNumber 查询实体
     * @return 所有数据
     */
    @GetMapping("/list")
    public TableDataInfo list(GameCarrierNumber gameCarrierNumber) {
        startPage();
        LambdaQueryWrapper<GameCarrierNumber> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(GameCarrierNumber::getGameCarrierId, gameCarrierNumber.getGameCarrierId());
        queryWrapper.orderByDesc(GameCarrierNumber::getId);
        List<GameCarrierNumber> list = gameCarrierNumberService.list(queryWrapper);
        return getDataTable(list);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(gameCarrierNumberService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param gameCarrierNumber 实体对象
     * @return 新增结果
     */
    @PostMapping
    public AjaxResult insert(@RequestBody GameCarrierNumber gameCarrierNumber) {
        gameCarrierNumber.setCreateId(getUserId());
        return toAjax(gameCarrierNumberService.save(gameCarrierNumber));
    }

    /**
     * 修改数据
     *
     * @param gameCarrierNumber 实体对象
     * @return 修改结果
     */
    @PutMapping
    public AjaxResult update(@RequestBody GameCarrierNumber gameCarrierNumber) {
        gameCarrierNumber.setUpdateId(getUserId());
        return toAjax(gameCarrierNumberService.updateById(gameCarrierNumber));
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(gameCarrierNumberService.removeByIds(Arrays.asList(ids)));
    }
}

